package com.spring.aop.interceptor;

import com.spring.aop.Advisor;
import com.spring.aop.InterceptorChain;

import java.lang.reflect.Method;

public class AfterReturningInterceptor extends Interceptor {
	public AfterReturningInterceptor(Advisor advisor) {
		super(advisor);
	}
	
	@Override
	public Object invoke(InterceptorChain chain, Object targetObject, Method targetMethod, Object[] args) throws Throwable {
		Object retVal = chain.proceed(targetObject, targetMethod, args);
		
		// 返回通知在这里,返回通知实际应该拥有修改返回值的能力
		advisor.afterReturning();
		
		return retVal;
	}
}
